<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>01.简易计算器</title>
	<style type="text/css">
		*{text-align: center;}
	</style>
</head>
<body>
	<h1>简易计算器</h1>
	<p>第一个数字：<input type="text" name="" id="input1"></p>
	<p>第二个数字：<input type="text" name="" id="input2"></p>
	<p> <input type="button" name="" value="+" onclick="getResult('+')">&nbsp&nbsp&nbsp&nbsp
		<input type="button" name="" value="-" onclick="getResult('-')">&nbsp&nbsp&nbsp&nbsp
		<input type="button" name="" value="*" onclick="getResult('*')">&nbsp&nbsp&nbsp&nbsp
		<input type="button" name="" value="/" onclick="getResult('/')"></p>
	<p>计算结果为：<span id="result">0</span></p>
</body>
<script type="text/javascript">
	function getResult(opa){
		var num1=Number(document.getElementById('input1').value);
		var num2=Number(document.getElementById('input2').value);
		switch(opa){
			case '+':
					result.innerText=num1+num2;
					break;
			case '-':
					result.innerText=num1-num2;
					break;
			case '*':
					result.innerText=num1*num2;
					break;
			case '/':
					result.innerText=num1/num2;
					break;
		}
	}
</script>
</html>